import 'package:get/get.dart';
import 'package:kkhousekeep/models/order_result_entity.dart';
import 'package:kkhousekeep/net/home_order_connect.dart';

import '../../../../models/order_list_entity.dart';
import '../../../public/take_picture_screen.dart';


class OrderResultController extends GetxController {
  late OrderListObj _orderEntity;
  var id = 0;
  late OrderResultEntity _orderResultEntity;
  var fatalType = "".obs;
  var standard = "".obs;
  var result = "".obs;
  var cause = "".obs;
  var propose = "".obs;
  var appraise = "".obs;
  var pics = <String>[].obs;
  var cost = 0.0.obs;
  var assistants = "".obs;
  late HomeOrderConnect _homeOrderConnect;

  @override
  void onInit() {
    _orderEntity = Get.arguments;
    _homeOrderConnect = Get.find<HomeOrderConnect>();
    super.onInit();
    _loadNetworkData();
  }

  Future<void> _loadNetworkData() async {
    _orderResultEntity =
        await _homeOrderConnect.getOrderResult(orderId: _orderEntity.id);
    OrderResultObj orderResultObj = _orderResultEntity.obj;
    fatalType.value = orderResultObj.fatalType;
    standard.value = orderResultObj.standard;
    result.value = orderResultObj.result;
    cause.value = orderResultObj.cause;
    propose.value = orderResultObj.propose;
    appraise.value = orderResultObj.appraise;
    fatalType.value = orderResultObj.fatalType;
    pics.value = orderResultObj.pics;
    cost.value = orderResultObj.cost;
    assistants.value = orderResultObj.assistants;
  }

  void clickImageItem(String path) {
    Get.to(
      DisplayPictureScreen(
        imagePath: path,
        isShowRetake: false,
      ),
    );
  }
}
